package com.wb.mas.utils;

import android.text.TextUtils;

import java.text.DecimalFormat;

/**
 * Copyright (C) 2018,
 * MoneyUtils
 * <p>
 * Description
 *
 * @author yue
 * @version 1.0
 * <p>
 * Ver 1.0, 2019-05-08, yue, Create file
 */
public class MoneyUtils {

    public static String formatShow(String money) {
        if (TextUtils.isEmpty(money)) {
            return "";
        }
        DecimalFormat df = new DecimalFormat("#,###");
        try {
            return df.format(Long.valueOf(money)).replaceAll(",",".");
        } catch (Exception e) {
            return money;
        }

    }

    public static String calculateMoney(String money, String free) {
        try {
            int total = (int) (Integer.valueOf(money) * Float.valueOf(free));
            return formatShow(String.valueOf(total));
        } catch (Exception e) {
            return "";
        }
    }
}
